#include<iostream>
using namespace std;
int exam4_37()
{
	int n, x, i,num=0,tmp;
	cin >> n >> x;
	for (i = 1; i <= n; i++)
	{
		tmp = i;
		while (tmp  >= 1)
		{
			if (tmp % 10 == x)
			{
				num = num + 1;
			}
			tmp /= 10;
		}
	}
	cout << num;
	return 0;
}